//
//  MainCell.m
//  ShareYOU
//
//  Created by 杨亭 on 14-12-26.
//  Copyright (c) 2014年 ShareYOU. All rights reserved.
//

#import "MainCell.h"

@implementation MainCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
 
        //cell显示
        self.amountShow = [[UILabel alloc] init];
        self.amountShow.backgroundColor = [UIColor redColor];
//        self.amountShow.numberOfLines = 0;
        [self.contentView addSubview: self.amountShow];
        [_amountShow release];
        
        self.dateShow = [[UILabel alloc] init];
        self.dateShow.backgroundColor = [UIColor yellowColor];
//        self.dateShow.numberOfLines = 0;
        [self.contentView addSubview: self.dateShow];
        [_dateShow release];
        
        self.typeShow = [[UILabel alloc] init];
        self.typeShow.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview: self.typeShow];
        [_typeShow release];
        
        self.commentShow = [[UILabel alloc] init];
        self.commentShow.backgroundColor = [UIColor purpleColor];
        [self.contentView addSubview: self.commentShow];
        self.dateShow.numberOfLines = 2;
        [_commentShow release];
        
        self.personnelShow = [[UILabel alloc] init];
        self.personnelShow.backgroundColor = [UIColor magentaColor];
        [self.contentView addSubview: self.personnelShow];
        [_personnelShow release];
        
        
    }
    return self;
}

//系统的方法, 在cell显示到屏幕之前, 最后调用的一个方法.
//在这个方法中, cell自己的高度和属性都是有值的, 而且是最新的值
-(void)layoutSubviews
{
    [super layoutSubviews];
    CGFloat width = self.contentView.frame.size.width / 4;
    CGFloat height = self.contentView.frame.size.height / 2;
    
    _amountShow.frame = CGRectMake(width + 10, 0, width - 10, height);
//    [_amountShow sizeToFit];
    _dateShow.frame = CGRectMake(20, 0, width - 10, height);
//    [_dateShow sizeToFit];
    _typeShow.frame = CGRectMake(width * 2, 0, width - 10, height);
    _personnelShow.frame = CGRectMake(width * 3 - 10, 0, width - 10, height);
    _commentShow.frame = CGRectMake(20, height, width * 4 - 40, height);
    
    

}












- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}




//释放内存
- (void)dealloc
{
    [_dateShow release];
    [_typeShow release];
    [_commentShow release];
    [_personnelShow release];
    [super dealloc];
}




@end
